package models

import "gorm.io/gorm"

type Hospital struct {
	gorm.Model
	HospitalName string  `json:"hospital_name" gorm:"type:varchar(30);not null;comment:医院名称"`
	Address      string  `json:"address" gorm:"type:varchar(30);not null;comment:医院地址"`
	Name         string  `json:"name" gorm:"type:varchar(30);not null;comment:医生姓名"`
	Cate         string  `json:"cate" gorm:"type:varchar(30);not null;comment:门科分类"`
	Price        float64 `json:"price" gorm:"type:decimal(10,2);not null;comment:挂号费用"`
	RoomAddress  string  `json:"room_address" gorm:"type:varchar(30);not null;comment:科室"`
}

func (h *Hospital) Creates() error {
	return DB.Create(&h).Error
}

func (h *Hospital) List(page, pageSize int) (hospital []Hospital, err error) {
	err = DB.Scopes(Paginate(page, pageSize)).Find(&hospital).Error
	return
}
